# def maopao():
#     list = [4, 9, 8]
#     length=len(list)
#     for i in range(length-1):
#         print('循环%d'%i)
#         for j in range(0,length-i-1):
#             if list[j]>list[j+1]:#列表元素两两相互比较，把最大值换到最后面
#                 list[j],list[j+1]=list[j+1],list[j]
#             print(list)
#
# print(maopao())
# for i in range(0,0):
#     print(i)
# from selenium import webdriver
#
# driver = webdriver.Firefox()
# driver.get('https://www.baidu.com/')
from selenium.webdriver.common.keys import Keys

# read_file=open('test_automation/lsd.txt','r',encoding='utf-8')
# for line in read_file:
#     print(line.strip())
# print(read_file.readline(),end='')
# print(read_file.readline())
# # print(read_file.read(19))
#
# read_file.close()
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.get("http://www.baidu.com/")
locator = (By.ID, "kw")
try:
    ele = WebDriverWait(driver,10).until(EC.presence_of_element_located(locator))
    driver.find_element_by_id("kw").send_keys("abc\n")
    driver.find_element_by_id('su').send_keys(Keys.ENTER)
   # driver.find_element(locator).send_keys("abc\n")
    time.sleep(2) # 为了看效果
except:
    print("ele cant find")
finally:

    print("无论如何都会关闭页面！")
    driver.quit()
